package com.sixth.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sixth.core.entity.OperLog;
import com.sixth.core.vo.R;
import com.sixth.system.service.OperLogInfoService;
import com.sixth.system.vo.OperLogInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 操作日志控制器
 *
 * @author Stu YH
 * @date Created in 2024/8/18 19:12
 * @description 提供操作日志相关的API接口
 * @modified By：
 * @version:
 */
@Api(tags = "操作日志管理")
@RestController
@RequestMapping("system/operLogInfo")
public class OperLogController {
    @Autowired
    private OperLogInfoService operLogInfoService;

    /**
     * 分页查询操作日志
     * @param operLogInfoVo 查询条件
     * @return 分页查询结果
     */
    @ApiOperation(value = "分页查询操作日志", notes = "根据查询条件分页查询操作日志列表")
    @PostMapping("/listByPage")
    public R<IPage<OperLog>> list(@RequestBody OperLogInfoVo operLogInfoVo) {
        return operLogInfoService.selectByPage(operLogInfoVo);
    }

    /**
     * 删除操作日志
     * @param ids 操作日志ID数组
     * @return 删除结果
     */
    @ApiOperation(value = "删除操作日志", notes = "根据操作日志ID数组删除操作日志")
    @GetMapping("/deleteoperLoginfoByIds/{ids}")
    public R deleteLoginInfoById(@PathVariable Long[] ids) {
        return operLogInfoService.removeByIds(ids);
    }

    /**
     * 清空所有操作日志数据
     * @return 清空结果
     */
    @ApiOperation(value = "清空所有操作日志数据", notes = "清空所有操作日志记录")
    @GetMapping("/deleteAll")
    public boolean deleteAll() {
        return operLogInfoService.deleteAll();
    }

    /**
     * 添加操作日志数据
     * @param operLog 操作日志对象
     * @return 添加结果
     */
    @ApiOperation(value = "添加操作日志数据", notes = "添加一条操作日志记录")
    @PostMapping("/save")
    public R save(@RequestBody OperLog operLog) {
        return operLogInfoService.save(operLog);
    }
}
